package com.cps116.parcelables;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

public class Coordinate implements Parcelable{

	private double latCoord;
	private double longCoord; 

	
	public Coordinate(double latCoord, double longCoord)
	{
		this.latCoord = latCoord;
		this.longCoord = longCoord;
	}
	
	
	public int describeContents() {
		return 0;
	}

	public void writeToParcel(Parcel dest, int flags) {

		Log.d("Point", "Point write to parcel starts");
		Log.d("Point", "write lat:" + latCoord);
		dest.writeDouble(latCoord);
		Log.d("Point", "write long:" + longCoord);
		dest.writeDouble(longCoord);
	}
	
	
	public void readFromParcel(Parcel in) {
		
		Log.d("Point", "Point read from parcel starts");
		latCoord = in.readDouble();
		Log.d("Point", "read lat:" + latCoord);
		longCoord = in.readDouble();	
		Log.d("Point", "read long:" + longCoord);

	}
	
	
	//create the PARCELABLE CREATOR CLASS
	public static final Parcelable.Creator<Coordinate> CREATOR
	= new Parcelable.Creator<Coordinate>() {
		
		public Coordinate createFromParcel(Parcel in) {
			return new Coordinate(in);
		}

		public Coordinate[] newArray(int size) {
			return new Coordinate[size];
		}
	};	


	private Coordinate(Parcel in)
	{
		readFromParcel(in);
	}
	
	
	// the GETTERS AND SETTER METHODS!!!!!!!!
	public double getLatCoord() {
		return latCoord;
	}


	public void setLatCoord(double latCoord) {
		this.latCoord = latCoord;
	}


	public double getLongCoord() {
		return longCoord;
	}


	public void setLongCoord(double longCoord) {
		this.longCoord = longCoord;
	}
	
	
}
